const Router = require('koa-router');
var router = new Router({
    prefix:'/word'
})

const query = require('./query')

router.get('/api/article', async(ctx, next)=>{
	try {
		var data = {}

		var getWriterID = await query('SELECT * FROM dianzan WHERE lid = 30');

		data.id = getWriterID[0].lid

		ctx.response.body = data
		  
	}catch (e) {
		ctx.response.body = e
	}
})

router.post('/api/test',async(ctx,next)=>{
	try {
		var data = {}

		// var getData = JSON.parse(Object.keys(ctx.request.body)[0])

		// data.name = getData.name

		// data.age = getData.age

		// var getWriterID = await query('SELECT * FROM article WHERE aid = 1');

		// data.id = getWriterID[0].uid

		// ctx.response.body = data
		  
	}catch (e) {
		ctx.response.body = e
	}	
})

module.exports = router